<template>
  <el-table v-loading="loading" :data="containerList" @selection-change="handleSelectionChange">
    <el-table-column type="selection" width="55" align="center" />
    <el-table-column type="index" label="序号" width="60" align="center" />
    <el-table-column label="器具编码" align="left" prop="containerCode" width="140" :show-overflow-tooltip="true" />
    <el-table-column label="器具型号" align="left" prop="materialName" width="120" :show-overflow-tooltip="true" />
    <el-table-column label="型号编码" align="left" prop="materialCode" width="120" :show-overflow-tooltip="true" />
    <el-table-column label="当前仓库" align="left" prop="currentWarehouseName" width="100" :show-overflow-tooltip="true" />
    <el-table-column label="位置状态" align="center" prop="locationStatus" width="80">
      <template slot-scope="scope">
        <el-tag v-if="scope.row.locationStatus == '1'" type="success" size="mini">在库</el-tag>
        <el-tag v-else-if="scope.row.locationStatus == '2'" type="warning" size="mini">在途</el-tag>
        <span v-else>-</span>
      </template>
    </el-table-column>
    <el-table-column label="业务状态" align="center" prop="businessStatus" width="80">
      <template slot-scope="scope">
        <el-tag v-if="scope.row.businessStatus == '1'" type="success" size="mini">正常</el-tag>
        <el-tag v-else-if="scope.row.businessStatus == '2'" type="info" size="mini">封存</el-tag>
        <el-tag v-else-if="scope.row.businessStatus == '3'" type="warning" size="mini">维修</el-tag>
        <el-tag v-else-if="scope.row.businessStatus == '4'" type="danger" size="mini">报废</el-tag>
        <span v-else>-</span>
      </template>
    </el-table-column>
    <el-table-column label="装箱状态" align="center" prop="packingStatus" width="80">
      <template slot-scope="scope">
        <el-tag v-if="scope.row.packingStatus == '1'" type="info" size="mini">空箱</el-tag>
        <el-tag v-else-if="scope.row.packingStatus == '2'" type="success" size="mini">满箱</el-tag>
        <span v-else>-</span>
      </template>
    </el-table-column>
    <el-table-column label="当前项目" align="left" prop="currentProjectName" width="120" :show-overflow-tooltip="true" />
    <el-table-column label="定位器编码" align="left" prop="locatorCode" width="120" :show-overflow-tooltip="true" />
    <el-table-column label="生产日期" align="center" prop="productionDate" width="100">
      <template slot-scope="scope">
        <span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d}') }}</span>
      </template>
    </el-table-column>
    <el-table-column label="创建时间" align="center" prop="createTime" width="100">
      <template slot-scope="scope">
        <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" align="center" width="200" fixed="right" class-name="small-padding fixed-width">
      <template slot-scope="scope">
        <el-button
          size="mini"
          type="text"
          icon="el-icon-view"
          @click="handleDetail(scope.row)"
          v-hasPermi="['pack:container:query']"
        >详情</el-button>
        <el-button
          size="mini"
          type="text"
          icon="el-icon-edit"
          @click="handleUpdate(scope.row)"
          v-hasPermi="['pack:container:edit']"
        >修改</el-button>
        <el-button
          size="mini"
          type="text"
          icon="el-icon-delete"
          @click="handleDelete(scope.row)"
          v-hasPermi="['pack:container:remove']"
        >删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: 'ContainerTable',
  props: {
    loading: {
      type: Boolean,
      default: false
    },
    containerList: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    handleSelectionChange(selection) {
      this.$emit('selection-change', selection)
    },
    handleDetail(row) {
      this.$emit('detail', row)
    },
    handleUpdate(row) {
      this.$emit('update', row)
    },
    handleDelete(row) {
      this.$emit('delete', row)
    }
  }
}
</script>
